package com.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;


@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AjaxResult {
    private String code;
    private String msg;
    private Object data;

    public static AjaxResult success(String msg,Object data) {
        return AjaxResult.builder()
                .code("200")
                .msg(msg)
                .data(data)
                .build();
    }
    public static AjaxResult success(Object data) {
        return success("操作成功",data);
    }

    public static AjaxResult success() {
        return success(null);
    }

    public static AjaxResult error(String msg,Object data) {
        return AjaxResult.builder()
                .code("500")
                .msg(msg)
                .data(data)
                .build();
    }

    public static AjaxResult error() {
        return error("操作失败",null);
    }
}
